<template>
	<eui-popup ref="confirmApplyOrderPopup" :type="type" background-color="#fff" :mask-click="false">
		<view class="popup-content">
			<view class="popup-title flex just-between">
				<view style="font-weight: bold;">
					请选择售后类型
				</view>
				<bcm-close-btn @click="close" />
			</view>
			<view v-if="scope.returnGoodsType == '2' && scope.isRefundAll == '0'"
				style="padding: 8rpx 8rpx 8rpx 30rpx;box-sizing: border-box;height: 20vh;text-align: left;">
				部分退款订单将继续履约，您确定要退款给顾客吗？
			</view>
			<view v-if="scope.returnGoodsType == '1' || (scope.returnGoodsType == '2' && scope.isRefundAll == '1')"
				style="padding: 8rpx 8rpx 8rpx 30rpx;box-sizing: border-box;height: 20vh;text-align: left;">
				此操作将取消订单，您确定要退款给顾客吗？</view>
			<view class="bottom-1">
				<eui-button type="max2" :title="scope.dealType == '1' ? '退货退款' : '仅退款'" style="width: 45%;"
					singleTag="confirmApplyOrderCancel" @click="confirmApply('confirmApplyOrderCancel')" />
				<eui-button type="max" :title="scope.dealType == '1' ? '仅退款' : '退货退款'" style="width: 45%;"
					@click="confirmApply('confirmApplyOrderSure')" />
			</view>
		</view>
	</eui-popup>
</template>
<script>
import BcmCloseBtn from '../../components/BcmCloseBtn.vue';
export default {
	name: "ConfirmApplyOrderPopup",
	props: {
		scope: {
			type: Object,
			default: {}
		},
		type: {
			type: String,
			default: 'bottom'
		},
		show: {
			type: Boolean,
			default: false
		},
	},
	components: {
		BcmCloseBtn
	},
	watch: {
		show: {
			handler(val) {
				if (val) {
					this.$refs.confirmApplyOrderPopup.open('bottom');
				} else {
					this.close()
				}
			},
		}
	},
	data() {
		return {

		}
	},
	methods: {
		close() {
			this.$refs.confirmApplyOrderPopup.close();
			this.$emit('close');
		},
		confirmApply(type) {
			let _this = this;
			if (type == 'confirmApplyOrderCancel') {
				this.confirmAfsApplyOrder(_this.scope, _this.scope.dealType == '1' ? '2' : '1')
			} else {
				this.confirmAfsApplyOrder(_this.scope, _this.scope.dealType == '1' ? '1' : '2')
			}
		},
		confirmAfsApplyOrder(v, dealType) {
			if (dealType == '2') {
				this.$emit('updateConfirmApply')
			} else {
				this.confirmAcceptApplyOrder(v, dealType)
			}
		},
		confirmAcceptApplyOrder(v, dealType, showModal = false) {
			let text = '';
			if (v.returnGoodsType == '2' && v.isRefundAll == '0') {
				text = "部分退款订单将继续履约，您确定要退款给顾客吗？"
			}
			if (v.returnGoodsType == '1' || (v.returnGoodsType == '2' && v.isRefundAll == '1')) {
				text = "此操作将取消订单，您确定要退款给顾客吗？"
			}
			// console.log('=====>confirmAcceptApplyOrder', JSON.stringify(v));
			if (showModal) {
				uni.showModal({
					title: '提示',
					content: text,
					showCancel: true,
					success: (res) => {
						if (res.confirm) {
							this.$emit('orderAction', dealType,v)
						} else { }
					}
				});
			} else {
				this.$emit('orderAction', dealType,v)
			}
		}
	}
}
</script>
<style lang="scss" scoped>
@import "@/static/font/enjoyicon/iconfont.css";
@import "../../common/common.css";

.popup-content {
	display: flex;
	flex-direction: column;
	width: 100%;
	padding: 0;
	background-color: #fff;

	.popup-title {
		display: flex;
		align-items: center;
		box-sizing: border-box;
		width: 100%;
		height: 100rpx;
		padding-right: 36rpx;
		padding-left: 30rpx;
		font-size: 33rpx;
		line-height: 100rpx;
		border-bottom: 1rpx solid #f1f1f1;
	}
}

.bottom-1 {
	display: flex;
	justify-content: center;
	flex: 0 0 auto;
	height: 70rpx;
	padding: $uni-spacing-col-sm * 2 $uni-spacing-row-sm;
	background: $uni-bg-color;
	// border-top: 1rpx solid #979797;
}
</style>